﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WF.Common;

namespace WF.Web.Pages.Workflow.KQ
{
    public partial class ApplyList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsRebind)
            {
                this.dataListView.DataBind();
            }
            if (!IsPostBack)
            {
                txtDateStart.Text = System.DateTime.Now.ToString("yyyy-MM-") + "01";
                txtDateEnd.Text = System.DateTime.Now.ToString("yyyy-MM-") + CentaUtil.GetDaysOfMonth(System.DateTime.Now).ToString();
                this.InitSearch();
            }
        }

        #region 私有方法
        private void InitSearch()
        {
            //只查本人
            if (null != Request["isMine"] && Request["isMine"] == "1")
            {
                this.cbxIsMine.Checked = true;
                this.cbxIsMine.Visible = false;
                this.ToolBar1.OnClinetClickBack = "../../workspace/myapply.aspx";
            }
            else
            {
                this.ToolBar1.OnClinetClickBack = "../../workspace/QueryApply.aspx";
                //只有有权限的人才能查询所有申请
                string users = System.Configuration.ConfigurationManager.AppSettings["ApplyQueryUser"];
                //string users = "jiangx,luosk";
                // string LoginName = "jiangx";
                SessionManager sm = new SessionManager();
                UserProfile user = sm.CurrentUser;
                //if (!string.IsNullOrEmpty(user.LoginName))
                //    LoginName = user.LoginName.Split('\\')[1];
                string strLoginName = user.LoginName.ToLower();
                if (users.Contains(strLoginName))
                    this.cbxIsCanQuery.Checked = true;
                else
                    this.cbxIsCanQuery.Checked = false;
            }
        }
        #endregion

        #region PUBLIC 方法
        public string FormatState(string itype)
        {
            string _result = "";
            switch (itype)
            {
                case "1":
                    _result = "通过";
                    break;
                case "-1":
                    _result = "拒绝";
                    break;
                case "0":
                    _result = "审核中";
                    break;
            }
            return _result;
        }
        #endregion
    }
}